<%--
  Created by IntelliJ IDEA.
  User: 谢兴鑫
  Date: 2022/5/13
  Time: 上午 09:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加笔记</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxForm.js"></script>

</head>
<script>
    layui.use(['form', 'laydate', 'layer'], function () {
        var form = layui.form, laydate = layui.laydate, layer = layui.layer;
        laydate.render({
            elem: '#Time',
            type: 'date',//指定日期选择器类型 date,time,datetime
            trigger: 'click'
        });
        //自定义验证规则
        form.verify({
            v_sname: function (val, item) {//正则表达式验证规则
                if (/^\d+\d+\d$/.test(val)) {
                    return "用户名不能全为数字！！！"
                }
            },
            newmobile: function (value) {
                if (value.length != 11) {
                    return '新手机号必须为11位合法数字';
                }
                var reg = /^1(3|4|5|6|7|8|9)\d{9}$/;
                if (reg.test(value)) {
                    // return '手机号码格式正确';
                } else {
                    return '非法手机号';
                }
            },
            //邮箱验证
            email: function (value) {
                if (value.length < 7) {
                    return '邮箱至少得7个字符啊';
                }
                var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
                if (reg.test(value)) {
                    // return '邮箱格式正确';
                } else {
                    return '邮箱格式不正确';
                }
            }
        });

        //监听表单提交
        form.on('submit(formbtn)', function () {
            $("#formsbt").ajaxSubmit({
                type: "post",
                url: '${pageContext.request.contextPath}/holidaystudent/stuaddApply',
                success: function (data) {//添加成功的回调函数
                    var index = parent.layer.getFrameIndex(window.name);//获取Frame索引
                    parent.layer.close(index);//关闭当前frame
                    parent.layui.table.reload("tableData");//可以对父窗口进行刷新
                }
            });
        });
    });
</script>
<body>
<form class="layui-form" id="formsbt">

    <div class="layui-form-item">
        <div class="layui-input-inline">
            <input type="hidden" name="holidayId" id="holidayId" placeholder="学生编号" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-inline">
            <input type="hidden" name="stuId" id="stuId" value="${sessionScope.STUID}"  class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">天数</label>
        <div class="layui-input-inline">
            <input type="text" name="holidayDay" id="holidayDay" required lay-verify="required"
                   placeholder="请输入请假天数"
                   autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">截至时间</label>
        <div class="layui-input-inline">
            <input type="text" name="endTime" id="Time"
                   autocomplete="off"
                   class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">原因</label>
        <div class="layui-input-inline">
            <input type="text" name="title" id="title" required lay-verify="required" placeholder="原因"
                   autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-inline">
            <input type="text" name="remark" id="remark" required lay-verify="required" placeholder="备注"
                   autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-inline">
            <input type="hidden" name="processInstanceId" id="processInstanceId" value="stuLeave" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <button id="formbtn" type="button" lay-submit lay-filter="formbtn" class="layui-btn layui-btn-normal">
            保存
        </button>
        <button id="reset" type="reset" lay-submit lay-filter="formbtn" class="layui-btn layui-btn-normal">
            重置
        </button>
    </div>


</form>
<script>

</script>


</body>
</html>
